package day0116;

public class CellPhone {
    //1.成员变量用private修饰
    private String brand;//品牌//成员变量
    private String model;//型号
    private double price;

    public void test(){
        CellPhone c=new CellPhone();
        c.model="P90";
        System.out.println(c.model);
    }


    //4.toString(): 将对象的成员变量链接位一个字符串返回
    //打印一个CellPhone对象的时候，会自动调用toString()方法
    public String toString() {
        return "CellPhone{" +
                "brand='" + brand + '\'' +
                ", model='" + model + '\'' +
                ", price=" + price +
                '}';
    }

    //3.get和set方法
    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    //getBrand(): 用来返回brand成员变量的属性值
    public  String   getBrand(){
        return brand;
    }

    public String setBrand(String brand) {
        this.brand = brand;
        return this.brand;
    }

    //2.构造方法//alt  insert
    public CellPhone() {
    }
    public CellPhone(String b, String model, double price) {
        this.brand = b;
        this.model = model;
        this.price = price;
    }
}



class TestCellPhone {
    public static void main(String[] args) {
        //调用setBread
        CellPhone c1=new CellPhone();

        String b=c1.setBrand("华为");
        System.out.println(b);

        c1.setPrice(7999.1);
        double d=c1.getPrice();
        System.out.println(d);

        String  s=c1.toString();
        System.out.println(s);

        System.out.println(c1);//会自动调用toString()方法
        //day0115.CellPhone@232204a1
        //包名.类名@16进制地址值

    }
}




interface   A{}
interface   B{}
interface   C  extends  A,B{}


class A2{
    void a(String a,int b){}
}

class Test extends A2{
    void a(String a){}//
    void a(String a,int b){}//
}






interface X{//李渊
    int a=1;
    public void b();
}
class XClassChild implements X{//李世民
    int a=10;
    public void b(){}
}

class YClassChild implements X{//李元霸
    int a=10;
    public void b(){}
}

class TestX{
    public static void main(String[] args) {
        X  obj=new XClassChild();
        //属性(成员变量): 属性绑定到类型上
        //方法绑定到对象上。
        XClassChild y=(XClassChild)obj;//obj.b();  //可以将一个子类型转化父类型
        //可以将一个父类型对象转化 创建此对象的类所属的类型
        //不能将一个对象转化为它的兄弟类型。



        X  y2=new YClassChild();
        if(y2 instanceof XClassChild){
            XClassChild  x2=(XClassChild)y2;
        }



    }
}






class Test40{
    //public void a(){}

    public static void  main(){
        Test40 t=new Test40(){
            //public int a(){}
        };
        //new Test(){}
        //public int a
        //() -> {}
        //Test40 t=()->{};
    }

}


